package LeetCode.Hash;

import java.util.HashSet;
import java.util.Set;

/**
 * @author : LdLtd
 * @Date : 2023/8/2
 * @Description:822. 翻转卡片游戏
 */
public class card_flipping_game {
    public static void main(String[] args) {

    }
    class Solution {
        public int flipgame(int[] fronts, int[] backs) {
            Set<Integer> set = new HashSet<>();
            //先把正反面都一样的加入set中，
            for (int i = 0; i < fronts.length; i++) {
                if(fronts[i]==backs[i]){
                    set.add(fronts[i]);
                }
            }
            int res=3000;
            for (int i = 0; i < fronts.length; i++) {
                if(!set.contains(fronts[i])&&fronts[i]<res)
                res=fronts[i];
            }
            for (int i = 0; i < backs.length; i++) {
                if(!set.contains(backs[i])&&backs[i]<res)
                    res=backs[i];
            }
            return res%3000;
        }
    }
}
